package com.anxin.anxin_accident.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class OpenAPIConfig {

    //api接口显示
    @Bean
    public GroupedOpenApi accidentReportManagementApi() {
        return GroupedOpenApi.builder()
                .group("01-事故调查报告管理相关接口")
                .pathsToMatch("/accidentReportManagement/**")
                .build();
    }



    //header内容如用来模拟登陆
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI()
                .components(new Components()
                        .addSecuritySchemes("loginHeader", new SecurityScheme()
                                .type(SecurityScheme.Type.APIKEY)
                                .in(SecurityScheme.In.HEADER)
                                .name("userId")))
                .addSecurityItem(new SecurityRequirement().addList("loginHeader"));
    }
}
